﻿# coding: utf-8

import time
import wx
from wxFramework.wxMainFrame import wxMainFrame

class wxWorldEditorApp(wx.PySimpleApp):
	def OnInit(self):
		IL.LoadAllImages()
		
		self._keepGoing = False
		self._mainFrame = wxMainFrame()
		
		self._mainFrame.Centre(wx.BOTH)
		self._mainFrame.Show(True)
		self.SetTopWindow(self._mainFrame)
		
		self._keepGoing = True
		
		return True
		
	def GetMainFrame(self):
		return self._mainFrame
	    
	def MainLoop(self):
		evtloop = wx.EventLoop()
		old = wx.EventLoop.GetActive()
		wx.EventLoop.SetActive(evtloop)
		
		while self._keepGoing:
			WORLD_EDITOR.Update()
			WORLD_EDITOR.Render()
						
			while evtloop.Pending():
				evtloop.Dispatch()
			self.ProcessIdle()
			
			time.sleep(0.001)
	
		wx.EventLoop.SetActive(old)
		    
	def Initialize(self):
		GLOBAL_SETTING.Apply()